export class Piece extends Phaser.GameObjects.Image {
  // 棋子类
  init() {
    this.key = this.texture.key
  }
  constructor(scene, x, y, name, chessBoard, row, col, size) {
    super(scene, x, y, name)
    scene.add.existing(this)

    this.chessBoard = chessBoard
    this.setDataEnabled()
    this.setData({
      "row": row,
      "col": col
    })
    this.setData()
    this.setScale((chessBoard.cellW - 4) / this.width)
    // this.img.setSize(this.cellW,this.cellH) // 无效   
    this.init()
    this.size = size
    this.sizeText = this.scene.add.text(this.x, this.y, this.size, {
      fontSize: 20,
      color: name == 'pieceBlack' ? '#fff' : '#000'
    })
    this.sizeText.setOrigin(0.5, 0.5)
    this.sizeText.setVisible(false)
  }

}
